Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering workflows by more than one status value #41

Merged

Conversation

IvanRibakov
Copy link
Contributor

@IvanRibakov IvanRibakov commented Oct 2, 2024

This PR turns --status flag into a slice of strings, allowing to filter by more than one status value.

Primary motivation for this change is to be able to exclude cancelled workflow runs from the success/failure analysis as we are using cancel-in-progress: true workflow setting which results in quite a big number of cancelled jobs that significantly skew reported success/failure rate:

$ gh workflow-stats ... --created ">=2024-09-25"
🏃 Total runs: 32
  ✔ Success: 12 (37.5%)
  ✖ Failure: 10 (31.2%)
  🤔 Others: 10 (31.2%)

$ gh workflow-stats ... --created ">=2024-09-25" -s success,failure
🏃 Total runs: 22
  ✔ Success: 12 (54.5%)
  ✖ Failure: 10 (45.5%)
  🤔 Others: 0 (0.0%)

P.S.

This PR also fixes a bug where using previous status filter implementation did NOT correctly filter all run attempts by status as only the last attempts were filtered while previous run attempts were added to the result set without filtering by status.

@IvanRibakov
Copy link
Contributor Author

Hi, @fchimpan is there anything I can do to help you review/merge this PR?

@fchimpan
Copy link
Owner

fchimpan commented Oct 3, 2024

Hi, @IvanRibakov
Thank you for the great PR! I plan to take some time over the weekend to review it, so please wait a little. Thanks!

@IvanRibakov
Copy link
Contributor Author

Hi @fchimpan, any thoughts on the PR?

@@ -138,3 +125,43 @@ func workflowStats(cfg config, opt options, isJobs bool) error {

return nil
}

func fetchWorkflowRuns(ctx context.Context, client *github.WorkflowStatsClient, cfg config, opt options) ([]*go_github.WorkflowRun, error) {
Copy link
Owner

@fchimpan fchimpan Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought fetchWorkflowRuns function could be called directly within the client.FetchWorkflowRuns method rather than being defined as a separate function. Is there a specific reason why it was defined as a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why it was defined as a function?

Mainly to avoid bloating workflowStats function which is already fairly long. Feel free to adjust formatting to your liking.

Copy link
Owner

@fchimpan fchimpan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvanRibakov
Sorry for the delayed review, and thank you for the amazing feature addition! I believe there are no issues with the content.

@fchimpan
Copy link
Owner

@IvanRibakov
Understood, thank you! I think your suggestion is very good. I will refactor it on my side if necessary. Thanks again!

Copy link
Owner

@fchimpan fchimpan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@fchimpan fchimpan merged commit 78b1872 into fchimpan:main Oct 28, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants